package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 环节办理人多值
 * @author 代码创建
 */
public class FlowStepApproverVth extends AbstractTableBean {

	private String FlowId; //流程ID
	private String StepId; //环节ID
	private String FieldName; //字段类型
	private String Value; //值
	private String Label; //显示

	public static String TABLE_NAME = "Flow_StepApproverVth";
	public static String TABLEKEY_NAME = "VthId";
	public FlowStepApproverVth (IntegrateSql f){
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
	}

	public FlowStepApproverVth (IntegrateSql f,ResultSet rs) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		this.initParamToRs(rs);
	}

	public FlowStepApproverVth (IntegrateSql f,String keyValue) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		setCodePrepare(selectCodeById().toString());
		prepareSql.setPstValue(1, keyValue);
		ResultSet rs = executeQuery();
		if(rs.next()){
			initParamToRs(rs);
		}else{
			initParam();
		}
		rs.close();
	}

	@Override
	protected void initParam() {
		FlowId = ""; //流程ID
		StepId = ""; //环节ID
		FieldName = ""; //字段类型
		Value = ""; //值
		Label = ""; //显示
	}


	public void initParamToRs(ResultSet rs) throws SQLException{
		FlowId = rs.getString("FlowId"); //流程ID
		StepId = rs.getString("StepId"); //环节ID
		FieldName = rs.getString("FieldName"); //字段类型
		Value = rs.getString("Value"); //值
		Label = rs.getString("Label"); //显示
		this.setKeyId(rs.getString("VthId"));
	}


	@Override
	protected int appendData() throws SQLException {
		int i = 1;
		prepareSql.setPstValue(i++,FlowId); //流程ID
		prepareSql.setPstValue(i++,StepId); //环节ID
		prepareSql.setPstValue(i++,FieldName); //字段类型
		prepareSql.setPstValue(i++,Value); //值
		prepareSql.setPstValue(i++,Label); //显示
		return i;
	}


	@Override
	public Vector<String> getFields() {
		Vector<String> vec = new Vector<String>();
		vec.addElement("FlowId"); //流程ID
		vec.addElement("StepId"); //环节ID
		vec.addElement("FieldName"); //字段类型
		vec.addElement("Value"); //值
		vec.addElement("Label"); //显示
		return vec;
	}


	/**
	 * 设置流程ID
	 * @param flowid
	 */
	public void setFlowId(String flowid){
		FlowId = flowid;
	}
	/**
	 * 获取FlowId
	 * @return 流程ID
	 */
	public String getFlowId(){
		return FlowId;
	}

	/**
	 * 设置环节ID
	 * @param stepid
	 */
	public void setStepId(String stepid){
		StepId = stepid;
	}
	/**
	 * 获取StepId
	 * @return 环节ID
	 */
	public String getStepId(){
		return StepId;
	}

	/**
	 * 设置字段类型
	 * @param fieldname
	 */
	public void setFieldName(String fieldname){
		FieldName = fieldname;
	}
	/**
	 * 获取FieldName
	 * @return 字段类型
	 */
	public String getFieldName(){
		return FieldName;
	}

	/**
	 * 设置值
	 * @param value
	 */
	public void setValue(String value){
		Value = value;
	}
	/**
	 * 获取Value
	 * @return 值
	 */
	public String getValue(){
		return Value;
	}

	/**
	 * 设置显示
	 * @param label
	 */
	public void setLabel(String label){
		Label = label;
	}
	/**
	 * 获取Label
	 * @return 显示
	 */
	public String getLabel(){
		return Label;
	}

}
